<template>
	<view class="find">
		<view class="head">
			<view class="head-nav" @tap=change(0)>精选文章</view>
			<view class="head-nav" @tap=change(1)>品牌列表</view>
		</view>

		<view class="art" v-show="current == 0">
			<view class="list" v-for="item in article" :key="item.id">
				<view class="art-items">
					<view class="nav">
						<image class="img" :src="item.coverImg"></image>
						<view class="title">{{item.title}}</view>
						<view class="author">{{item.author}}</view>
					</view>
					<view class="bottom">
						<view class="count">
							<image src="../../static/icons/view.png" class="icon"></image>
							<view class="number">{{item.viewCount}}</view>
						</view>
						<view class="collect">
							<uni-icons type="star" size="20" :color="iscollected == true ? '#f00':''" @tap="collect()"></uni-icons>
						</view>
					</view>
				</view>
			</view>

		</view>

		<view class="brand" v-show="current == 1">
			<view class="list" v-for="item in Brand" :key="item.id">
				<view class="brand-item">
					<image class="img" :src="item.bigPic"></image>
					<view class="box">
						<view class="title">{{item.name}}</view>
						<view class="desc">{{item.brandStory}}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		findBrandsByPage,
		findArticleByPage
	} from "../../api/find/index.js"
	export default {
		data() {
			return {
				current: 0,
				article: '',
				Brand: '',
				iscollected:false
			};
		},
		methods: {
			change(index) {
				this.current = index
			},
			collect(){
				
			}
		},
		onLoad() {
			findBrandsByPage(1, 10).then(res => {
				console.log(res)
				this.Brand = res.data.rows
			});
			findArticleByPage(1, 10).then(result => {
				// console.log(result)
				this.article = result.data.rows
			})
		}
	}
</script>

<style lang="scss" scoped>
	.find {
		background-color: #F1ECE7;
	}

	.head {
		width: 100%;
		height: 44px;
		background-color: #354E44;
		color: #fff;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 16px;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 9999;

		.head-nav {
			width: 74px;
			height: 44px;
			line-height: 44px;
			padding: 0 8px;
		}

	}

	.art {
		margin-top: 50px;

		.art-items {
			width: 337px;
			height: 241px;
			border-radius: 12px;
			margin: 14px auto;
			background-color: #fff;
			overflow: hidden;

			.nav {
				width: 100%;
				height: 191px;
				position: relative;
				background-color: #8f8f94;

				.img {
					width: 100%;
					height: 191px;
				}

				.title {
					position: absolute;
					left: 10px;
					top: 122px;
					color: #fff;
					font-size: 24px;
					line-height: 34px;
				}

				.author {
					position: absolute;
					left: 10px;
					top: 158px;
					color: #fff;
					font-size: 15px;
					line-height: 21px;
				}
			}

			.bottom {
				height: 50px;
				padding: 0 30px;
				box-sizing: border-box;
				display: flex;
				justify-content: space-between;
				align-items: center;

				.count {
					display: flex;
					align-items: center;

					.icon {
						width: 20px;
						height: 20px;
						margin-right: 15px;
					}

					.number {
						color: #3e3e3e;
						font-size: 13px;
					}
				}
			}
		}
	}

	.brand {
		margin-top: 50px;

		.brand-item {
			margin: 15px;
			border-radius: 4px;
			overflow: hidden;
			background-color: #fff;

			.img {
				width: 100%;
				height: 240px;
			}

			.box {
				margin: 15px;
				border-radius: 4px;
				overflow: hidden;
				background-color: #fff;

				.title {
					font-size: 16px;
					line-height: 22px;
					color: #3e3e3e;
				}

				.desc {
					font-size: 11px;
					color: #b1b1b1;
					line-height: 15px;
					white-space: nowrap;
					overflow: hidden;
				}
			}
		}
	}
</style>
